package fr.mma.achievement.controller;

import java.util.HashMap;
import java.util.Map;

import fr.mma.achievement.exception.NoSuchAchievementException;
import fr.mma.achievement.model.AchievementType;

public class AchievementControllerFactory {
	private static final Map<AchievementType, AchievementController> controllerMap = new HashMap<AchievementType, AchievementController>();	
	static {
		controllerMap.put(AchievementType.CADET, new CountAchievementController(1));
		controllerMap.put(AchievementType.LIEUTENANT, new CountAchievementController(10));
		controllerMap.put(AchievementType.COMMANDANT, new CountAchievementController(20));
	}

	static AchievementController build(AchievementType type) throws NoSuchAchievementException {
		if(controllerMap.containsKey(type)) { 
		return controllerMap.get(type);
		} else {
			throw new NoSuchAchievementException(type);
		}
	}
}
